#ifndef _KEY_H
#define _KEY_H

#include <QtGui>
#include <qwidget.h>
class QPushButton;
class CKey : public QWidget {
    Q_OBJECT

public:
    enum {KEY_0, KEY_1, KEY_2, KEY_3,
          KEY_4, KEY_5, KEY_6, KEY_7,
          KEY_8, KEY_9,
          KEY_DOT,
          KEY_BACK,
          KEY_SPACE,
          KEY_RETURN,
          KEY_UPPER,

      KEY_A, KEY_B, KEY_C, KEY_D,
      KEY_E, KEY_F, KEY_G, KEY_H,
      KEY_I, KEY_J, KEY_K, KEY_L,
      KEY_M, KEY_N, KEY_O, KEY_P,
      KEY_Q, KEY_R, KEY_S, KEY_T,
      KEY_U, KEY_V, KEY_W, KEY_X,
      KEY_Y, KEY_Z,
      KEY_NUM};
    CKey(QWidget *parent = NULL);
    ~CKey();
    QTimer *KEYTimer;

    QPoint lastPos;

private:
    void updateKeyText();
    void updateAlphaKeyText();

protected:
    void mousePressEvent(QMouseEvent *mouseEvent);
    void mouseMoveEvent(QMouseEvent *mouseEvent);
    void mouseReleaseEvent(QMouseEvent *);
    QPoint startPos;
    bool keyMovePressed;

signals:
    void characterGenerated(QChar keyValue);

private slots:
    void rxClicked();
    void startTimer();//判断是否长按，开启定时器
    void stopTimer();//关闭定时器
    void KeepOnResponse();

private:
    QPushButton *ppbKey[KEY_NUM];
    static bool bUpper;
    static char keyCode1[KEY_NUM];
    static char keyCode2[KEY_NUM];
};

#endif
